/**
 * 上海中赢金融信息服务有限公司
 * Copyright (c) 2017-2027 Chinazyjr,Inc.All Rights Reserved.
 */
package com.sys.midware.hbase.hcore.Optimize;

import com.sys.midware.hbase.config.BHBaseConfig;
import com.sys.midware.hbase.config.BHBaseConfigHolder;
import com.sys.midware.hbase.hcore.Optimize.OprimzeParam.BloomType;
import com.sys.midware.hbase.hcore.Optimize.OprimzeParam.CompressionAlgorithm;

/**
 * 列族参数优化
 * <b>ClassName：</b> ColumnFamilyOptimize <br/>
 * <b>Description：</b> TODO <br/>
 * <b>@author：</b> mobing <br/>
 * <b>@date：</b> 2015年10月26日 下午6:36:05 <br/>
 * <b>@version: </b>  <br/>
 */
public class ColumnFamilyOptimize {

    private String columnFamilyName;

    private int maxVersions = 3;// 指定数据最大保存的版本个数。默认为3。

    private int timeToLive = -1;// 指定最大的TTL,单位是ms,过期数据会被自动删除

    private boolean inMemory = false;// 指定是否放在内存中，对小表有用，可用于提高效率。默认关闭

    private BloomType bloomType;// 定是否使用BloomFilter,可提高随机查询效率。默认关闭。BloomFilter的类型

    private CompressionAlgorithm compressionAlgorithm;// 设定数据压缩类型。默认无压缩。压缩算法类型
    
    private BHBaseConfig BhbaseConfig;

    public ColumnFamilyOptimize(String columnFamilyName, int maxVersions, int timeToLive, boolean inMemory,
            BloomType bloomType, CompressionAlgorithm compressionAlgorithm) {
        super();
        this.columnFamilyName = columnFamilyName;
        this.maxVersions = maxVersions;
        this.timeToLive = timeToLive;
        this.inMemory = inMemory;
        this.bloomType = bloomType;
        this.compressionAlgorithm = compressionAlgorithm;
        
    }

    /**
     * 默认已经优化 maxVersions 1 BloomType.ROW CompressionAlgorithm.GZ
     * 
     * @param columnFamilyName
     */
    public ColumnFamilyOptimize(String columnFamilyName) {
        BhbaseConfig = BHBaseConfigHolder.get();
        this.columnFamilyName = columnFamilyName;
        this.timeToLive = -1;
        this.inMemory = false;
        this.maxVersions = BhbaseConfig.getHbaseCFMaxVersions();
        this.bloomType = Enum.valueOf(BloomType.class, BhbaseConfig.getHbaseCFBloomType());
        this.compressionAlgorithm = Enum.valueOf(CompressionAlgorithm.class,
                BhbaseConfig.getHbaseCFCompressionAlgorithm());

    }

    // /**
    // *
    // * NONE:Bloomfilters disabled ROW:Bloom enabled with Table row as Key
    // * ROWCOL:Bloom enabled with Table row & column (family+qualifier) as
    // * Key
    // *
    // */
    // public static enum BloomType {
    // NONE, ROW, ROWCOL
    // }
    //
    // /**
    // * LZO: GZ: NONE: SNAPPY: LZ:
    // *
    // */
    // public static enum CompressionAlgorithm {
    // LZO, GZ, NONE, SNAPPY, LZ
    // }

    public int getMaxVersions() {
        return maxVersions;
    }

    public void setMaxVersions(int maxVersions) {
        this.maxVersions = maxVersions;
    }

    public int getTimeToLive() {
        return timeToLive;
    }

    public void setTimeToLive(int timeToLive) {
        this.timeToLive = timeToLive;
    }

    public boolean isInMemory() {
        return inMemory;
    }

    public void setInMemory(boolean inMemory) {
        this.inMemory = inMemory;
    }

    public BloomType getBloomType() {
        return bloomType;
    }

    public void setBloomType(BloomType bloomType) {
        this.bloomType = bloomType;
    }

    public CompressionAlgorithm getCompressionAlgorithm() {
        return compressionAlgorithm;
    }

    public void setCompressionAlgorithm(CompressionAlgorithm compressionAlgorithm) {
        this.compressionAlgorithm = compressionAlgorithm;
    }

    public String getColumnFamilyName() {
        return columnFamilyName;
    }

}
